package by.pavlyukevich.paymentsystem.util;

import javax.persistence.metamodel.SingularAttribute;

public class PagingParams<Entity> {
	private SingularAttribute<Entity, ?> sortParam;
	private boolean ascending;
	private int startPosition;
	private int maxResult;

	{
		sortParam = null;
		ascending = true;
		startPosition = 0;
		maxResult = 0;
	}

	public SingularAttribute<Entity, ?> getSortParam() {
		return sortParam;
	}

	public PagingParams<Entity> setSortParam(SingularAttribute<Entity, ?> sortParam) {
		this.sortParam = sortParam;
		return this;
	}

	public boolean getAscending() {
		return ascending;
	}

	public PagingParams<Entity> setAscending(boolean ascending) {
		this.ascending = ascending;
		return this;
	}

	public int getStartPosition() {
		return startPosition;
	}

	public PagingParams<Entity> setStartPosition(int startPosition) {
		this.startPosition = startPosition;
		return this;
	}

	public PagingParams<Entity> setStartPosition(long startPosition) {
		this.startPosition = (int) startPosition;
		return this;
	}

	public int getMaxResult() {
		return maxResult;
	}

	public PagingParams<Entity> setMaxResult(int maxResult) {
		this.maxResult = maxResult;
		return this;
	}

	public PagingParams<Entity> setMaxResult(long maxResult) {
		this.maxResult = (int) maxResult;
		return this;
	}

}
